package com.tianpengtech.common.handler;

import java.util.Enumeration;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jfinal.aop.Interceptor;
import com.jfinal.handler.Handler;

public class H5AdHandler extends Handler{

	@Override
	public void handle(String target, HttpServletRequest request, HttpServletResponse response, boolean[] isHandled) {
		
		if(target.startsWith("/h5")){
			int index =target.lastIndexOf(".");
			if(index!=-1){
				target = target.substring(0, index);
				String param=target.replace("/h5/", "");
				request.setAttribute("page", param);
				Enumeration<String> enu=request.getParameterNames();  
				while(enu.hasMoreElements()){  
					String paraName=(String)enu.nextElement();  
					request.setAttribute(paraName, request.getParameter(paraName));
				}
				next.handle("/h5", request, response, isHandled);
			}
		}else{
			next.handle(target, request, response, isHandled);
		}
		
	}

}
